# -*- coding: utf-8 -*-
import DB_Driver as DB


class u_zone_node:
    ctype = ('播放', '歌单', '频道')
    showmode = ('列表1', '列表2', '海报1', '海报2')


class u_actor:
    crank = ('正常', '严重暴力', '中度暴力', '轻微暴力', '严重黄色', '中度黄色', '轻微黄色')
    status = {'cname': '状态', 'value': ('正在审核', '认证通过', '临时禁用', '永久禁用', '认证失败')}


class u_video:
    state = {'cname': '等级', 'value': ('正常', '严重暴力', '中度暴力', '轻微暴力', '严重黄色', '中度黄色', '轻微黄色')}



# 用户点赞\关注\取消关注\访问
class u_user_action:
    act = ('点赞(用户)', '关注', '访问', '取消关注','点赞(视频)','点赞(直播间)')

# 投诉
class u_user_complain:
    ctype = ('黄色', '暴力')
    cstate = {'cname': '状态', 'value': ('未评定', '真', '假')}


# 体现
class u_user_getcash:
    cstate = {'cname': '状态', 'value': ('未审核', '审核通过', '审核未通过', '自动通过')}
    cstate_show = ('未审核', '审核通过', '审核未通过')


# 充值
class u_user_recharge:
    ctype = {'cname': '类型', 'value': ('wechat', '支付宝', 'apple pay', '管理员充值')}


# 日志
class u_user_log:
    ctype = {'cname': '类型', 'value': ('送礼', '投诉', '观看', '充值', '提现')}
    ctype_index = ('0', '1', '2', '3', '4')


# 消费
class u_user_consume:
    ctype = {}


# 用户
class u_user:
    is_used = {'cname': '状态', 'value': ('禁用', '启用')}
    gender = ('男', '女','未知')
    ctype = ('普通注册用户', 'qq用户', '微信用户')


# 礼物
class u_gift:
    is_click_again = ('否', '是')


class u_config:
    def getData(self):
        # print('u_config.querydata')
        db =DB.getDB()
        res = {}
        row = db.queryOne("select pval from config where pkey='access_key' and ver='1.0.0'")
        res['access_key'] = row['pval']
        row = db.queryOne("select pval from config where pkey='secret_key' and ver='1.0.0'")
        res['secret_key'] = row['pval']
        row = db.queryOne("select pval from config where pkey='AppKey' and ver='1.1.0'")
        res['AppKey'] = row['pval']
        row = db.queryOne("select pval from config where pkey='AppSecret' and ver='1.1.0'")
        res['AppSecret'] = row['pval']
        row = db.queryOne("select pval from config where pkey='url_img' and ver='1.0.1'")
        res['url_img'] = row['pval']
        row = db.queryOne("select pval from config where pkey='bucket_name' and ver='1.0.1'")
        res['bucket_name_img'] = row['pval']
        row = db.queryOne("select pval from config where pkey='url_play' and ver='1.0.2'")
        res['url_play'] = row['pval']
        row = db.queryOne("select pval from config where pkey='bucket_name' and ver='1.0.2'")
        res['bucket_name_live'] = row['pval']
        row = db.queryOne("select pval from config where pkey='zone' and ver='1.0.3'")
        res['zone'] = row['pval']
        row = db.queryOne("select pval from config where pkey='APIID' and ver='1.0.4'")
        res['APIID'] = row['pval']
        row = db.queryOne("select pval from config where pkey='APIKEY' and ver='1.0.4'")
        res['APIKEY'] = row['pval']
        return res


class u_global:
    def getData(self):
        # print('u_global.querydata')
        res = {}
        db =DB.getDB()
        row = db.queryOne("select pval from global where pkey='fmoney'")
        res['fmoney'] = row['pval']
        row = db.queryOne("select pval from global where pkey='header'")
        res['header'] = row['pval']
        return res


class configOrglobal:
    res_global = None
    res_config = None


def getglobal():
    # print("getglobal")
    if configOrglobal.res_global == None:
        configOrglobal.res_global = u_global().getData()
    return configOrglobal.res_global


def getconfig():
    # print("getconfig")
    if configOrglobal.res_config == None:
        configOrglobal.res_config = u_config().getData()
    return configOrglobal.res_config


class datais:
    is_str = ('否', '是')
    dns_live = 'xiancity.cn'  # 直播空间域名
    res = getconfig()
    url_play = res['url_play']  # 播放地址
    url_img = res['url_img']  # 图片地址
    access_key = res['access_key']  # 七牛云密钥(Access Key)
    secret_key = res['secret_key']  # 七牛云密钥(Secret Key)
    AppKey = res['AppKey']  # 网易云信唯一对应的App Key
    AppSecret = res['AppSecret']  # 网易云信唯一对应的App Key
    APIID = res['APIID']  # 短信验证:用户名
    APIKEY = res['APIKEY']  # 短信验证:密码
    bucket_name_img = res['bucket_name_img']  # 七牛云要上传图片的空间
    bucket_name_live = res['bucket_name_live']  # 七牛云直播地址的空间
    zone = res['zone']  # 推荐位

    res = getglobal()
    header = res['header']  # 用户默认头像
    fmoney = res['fmoney']  # 虚拟币兑换比例

'''
            ret.code=200
            ret.msg = "请求成功!"
            ret.code=1001
            ret.msg = "用户不存在!"
            ret.code=1002
            ret.msg = "用户已注册!"
            ret.code=1003
            ret.msg = "验证码错误!"
            ret.code=1004
            ret.msg = "密码错误!"
            ret.code=1005
            ret.msg = "修改失败"
            ret.code=1006
            ret.msg = "使用网易云信异常"
            ret.code=1007
            ret.msg = "数据库操作异常"
            ret.code=1010
            ret.msg = "未知错误!"
            ret.code = 1011
            ret.msg = '直播间已经成功断流关闭'


'''